Back to course home
0% completed
Vote For New Content
LinkedIn Hard
Max Points on a Line (hard)
Solution: Max Points on a Line
Closest Binary Search Tree Value II (hard)
Solution: Closest Binary Search Tree Value II
Word Ladder (hard)
Solution: Word Ladder
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Largest Rectangle in Histogram (hard)
Solution: Largest Rectangle in Histogram
Serialize and Deserialize Binary Tree (hard)
Solution: Serialize and Deserialize Binary Tree
Remove Nth Node From End of List (Medium)
Problem Statement
Given a linked list, remove the last nth node from the end of the list and return the head of the modified list.
Example 1:
- Input: list = 1 -> 2 -> 3 -> 4 -> 5, n = 2
- Expected Output: 1 -> 2 -> 3 -> 5
- Justification: The 2nd node from the end is "4", so after removing it, the list becomes [1,2,3,5].
Example 2:
- Input: list = 10 -> 20 -> 30 -> 40, n = 4
- Expected Output: 20 -> 30 -> 40
- Justification: The 4th node from the end is "10", so after removing it, the list becomes [20,30,40].
Example 3:
- Input: list = 7 -> 14 -> 21 -> 28 -> 35, n = 3
- Expected Output: 7 -> 14 -> 28 -> 35
- Justification: The 3rd node from the end is "21", so after removing it, the list becomes [7,14,28,35].
Constraints:
- The number of nodes in the list is
sz. 1 <= sz <= 300 <= Node.val <= 1001 <= n <= sz
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Word Search
Solution: Remove Nth Node From End of List
Mark as Completed
On this page
Problem Statement
Try it yourself